package com.zhl.collection_traverse;

import java.util.ArrayList;
import java.util.Collection;

public class CollectionDemo2 {
    public static void main(String[] args) {
        Collection<String> collection = new ArrayList<>();
        collection.add("apple");
        collection.add("banana");
        collection.add("orange");
        collection.add("grape");
        collection.add("pear");

        // 遍历集合
        for (String fruit : collection) {
            System.out.println(fruit);
        }

        System.out.println("==============================");

        //遍历数组
        String[] fruits = {"apple", "banana", "orange", "grape", "pear"};
        for (String fruit : fruits) {
            System.out.println(fruit);
            }

    }
}
